package com.am.cell;

import java.util.List;

import com.am.IAMObject;
import com.am.link.Axon;
import com.am.link.HippoCampus;
import com.am.words.ICharacter;


public interface ICell extends IAMObject{
	public ICharacter getValue();
	public void setValue(ICharacter value);
	
	/**
	 * a cell is linkable if and only if it's in the current release state(CRS)
	 * the CRS duration is at most 2 UnitTime, each invocation of this method
	 * will increase 1 duration. so it should invoke only once in a round
	 * 
	 * if a cell is fired during current release, the CRS duration will be reset to 0
	 * 
	 * @return true if the cell is linkable
	 */
	public boolean isLinkable();
	
	/**
	 * if a cell is fired by input, we need manually make it relinkable
	 */
	public void reLinkable();
	
	/**
	 * currently we assume each fired cell can distribute 100mv
	 * @return
	 */
	public int getDistributableVoltage();
	
	/**
	 * the original voltage of a cell is -70mv, when it receives an additional +20mv voltage
	 * the cell is fired. if the voltage is less than +20mv, it will be stored for 1 UnitTime,
	 * then will be cleared
	 * 
	 * @param voltage
	 * @return fired, true means the cell is fired
	 */
	public boolean addVoltage(int voltage);
	
	/**
	 * if a cell receives voltage without being fired, we will keep the additional voltage for
	 * 1 UnitTime, during the time, if more additional voltage received and exceed the minimal voltage, the
	 * cell can be fired, otherwise, the voltage will be reset to the init status.
	 */
	public void resetVoltage();
	
	/**
	 * get all axon link start from this cell
	 * @return
	 */
	public List<Axon> getAxons();
	
	/**
	 * get Axon link start from this cell and end with the des cell
	 * @param des
	 * @return null if this link has not been created
	 */
	public Axon getAxon(ICell des);
	
	/**
	 * get all HippoCampus link start from this cell
	 * @return
	 */
	public List<HippoCampus> getHippoCampuses();
	
	/**
	 * get HippoCampus link start from this cell and end with the des cell
	 * @param des
	 * @return null if this link has not been created
	 */
	public HippoCampus getHippoCampus(ICell des);
	
	/**
	 * add a new axon link to this cell. this link starts from this cell
	 * and we only store id reference in the cell
	 * @param link
	 */
	public void addAxonLink(Axon link);
	
	/**
	 * add a new hippocampus link to this cell. this link starts from this cell
	 * and we only store id reference in the cell
	 * @param link
	 */
	public void addHippoCampusLink(HippoCampus link);
}
